<template>
    <div>
        <el-tabs v-model="activeName">
            <el-tab-pane label="评价效率" name="ef">
                <el-card>
                    <h1>导出评价效率</h1>
                    <div class="link_stu">
                        <el-link @click="dowloadEF" type="primary">评价效率下载</el-link>
                    </div>
                    <div class="download_stu">
                        <el-select v-model="schoolId_c" placeholder="请选择期数">
                            <el-option
                              v-for="(item,index) in options_stu"
                              :key="index"
                              :label="item.cg_periods"
                              :value="item.school_id">
                            </el-option>
                        </el-select>
                    <h1>总评价效率</h1>
                    <el-link @click="AEF" type="primary">查询 </el-link>
                     <div class="text primary-text">
                        <span class="all">{{this.allEfficiency | numFilter}}</span>
                     </div>
                    </div>
                </el-card>
            </el-tab-pane>
            <el-tab-pane label="课程得分" name="sc">
                <el-card>
                    <h1>导出课程得分</h1>
                    <div class="link_stu">
                        <el-link @click="dowloadSC" type="primary">课程得分下载</el-link>
                    </div>
                    <div class="download_stu">
                        <el-select v-model="schoolId_c" placeholder="请选择期数">
                            <el-option
                              v-for="(item,index) in options_stu"
                              :key="index"
                              :label="item.cg_periods"
                              :value="item.school_id">
                            </el-option>
                        </el-select>
                    </div>
                </el-card>
            </el-tab-pane>
            <el-tab-pane label="学生评价效率" name="sef">
                <el-card>
                    <h1>导出学生评价效率</h1>
                    <div class="link_stu">
                        <el-link @click="dowloadSEF" type="primary">学生评价效率下载</el-link>
                    </div>
                    <div class="download_stu">
                        <el-select v-model="schoolId_c" placeholder="请选择期数">
                            <el-option
                              v-for="(item,index) in options_stu"
                              :key="index"
                              :label="item.cg_periods"
                              :value="item.school_id">
                            </el-option>
                        </el-select>
                        
                    </div>
                </el-card>
            </el-tab-pane>
        </el-tabs>
    </div>
</template>

<script>
    import {SERVER_BASE} from "@/api/config";
    import fileImport from '@/api/fileImport';
    import axios from 'axios'

    export default {
        name: "infoImport",
        filters: {
            numFilter(value) {
            // 截取当前数据到小数点后两位
            let realVal = Number(value).toFixed(3)
            // num.toFixed(2)获取的是字符串
            return Number(realVal)
        }
    },
        data() {
            return {
                activeName: 'stu',
                value1: 'studentInfo',
                showDownloadLink:'',
                showDemo: false,
                dialogVisible:false,
                demoUrl:"",
                InfoDownloadLink: '',
                // temp_stu: SERVER_BASE + "/download?"+"course_type=1" + "&school_id=" + this.schoolId_c ,
                // temp_tea: SERVER_BASE + "/download?"+"course_type=2" + "&school_id=" + this.schoolId_c,
                // temp_course: SERVER_BASE + "/download?"+"course_type=3" + "&school_id=" + this.schoolId_c,
                schoolId: '',   // 上传学生信息期数ID
                schoolId_c: '', // 上传课程期数id区分一下
                options_stu: [],

                allEfficiency: '',
            }   
        },
        methods: {
            //获取期数信息
            getAllSchool() {
                let that=this;
                fileImport.getALLSchool().then(function (resp) {
                    if (resp.data.code == '200') {
                        that.options_stu = resp.data.data.list
                        console.log(that.options_stu)
                        console.log(that.options_stu[1])
                    } else {
                        that.$message.warning("期数获取失败!")
                    }
                })
            },
            dowloadEF(){
                location.replace(SERVER_BASE + "/downloadEvaluationEfficiency?school_id=" + this.schoolId_c)
            },
            dowloadSC(){
                location.replace(SERVER_BASE + "/downloadCourseOfScore?school_id=" + this.schoolId_c)
            },
            dowloadSEF(){
                location.replace(SERVER_BASE + "/downloadStudentEfficiency?school_id=" + this.schoolId_c)
            },
            AEF(){
                let that = this
                fileImport.getAllEfficiency(this.schoolId_c).then(function (resp) {
                    console.log(resp.data.data)
                    if (resp.data.code == '200') {
                        that.allEfficiency = resp.data.data
                    } else {
                        that.$message.warning("获取失败!")
                    }
                })
            },
        },
        mounted() {
            this.loginControl();  //登录控制
            this.getAllSchool(); //加载页面时，获取期数信息
            
        }
    }
</script>

<style scoped>
.download_stu {
    width: 50%;
}
.link_stu {
    position: absolute;
    right: 120px;
}
.demonstration {
    color: red;
}
.all{
    color:red;
}
</style>
<style>
    .upload-demo {
        margin-top: 15px;
    }
</style>